package zookeep;

import java.io.UnsupportedEncodingException;

/**
 * @author yinchengfeng
 * @date 2022/3/9
 * @Description:
 */
public class AppConfig {
    String appName;
    String host;
    String port;

    public AppConfig(String appName, String host, String port) {
        this.appName = appName;
        this.host = host;
        this.port = port;
    }

    public String getAppName() {
        return appName;
    }

    public void setAppName(String appName) {
        this.appName = appName;
    }

    public String getHost() {
        return host;
    }

    public void setHost(String host) {
        this.host = host;
    }

    public String getPort() {
        return port;
    }

    public void setPort(String port) {
        this.port = port;
    }

    @Override
    public String toString() {
        final StringBuilder sb = new StringBuilder("{");
        sb.append("\"appName\":\"")
                .append(appName).append('\"');
        sb.append(",\"host\":\"")
                .append(host).append('\"');
        sb.append(",\"port\":\"")
                .append(port).append('\"');
        sb.append('}');
        return sb.toString();
    }

    public byte[] getBytes() {
        try {
           return toString().getBytes("utf-8");
        } catch (UnsupportedEncodingException e) {
            e.printStackTrace();
            return null;
        }
    }
}
